package com.sun.controller.admin;


import com.alibaba.fastjson.JSON;
import com.sun.pojo.Checkin;
import com.sun.pojo.Employee;
import com.sun.service.ChartsService;
import com.sun.service.CheckinService;
import com.sun.utils.DataGridViewResult;
import com.sun.utils.SystemConstant;
import com.sun.vo.CheckinVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/charts")
public class ChartsController {
    @Autowired
    private ChartsService chartsService;

    @RequestMapping("/yearOfMoneyCharts")
    public String yearOfMoneyCharts(){
        List<Map> mapList = chartsService.yearOfMoneyCharts();
        List yearList=new ArrayList();
        List moneyList=new ArrayList();
        for (Map map : mapList) {
            yearList.add(map.get("years"));
            moneyList.add(map.get("money"));
        }
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("yearList",yearList);
        map.put("moneyList",moneyList);
        return JSON.toJSONString(map);
    }

    @RequestMapping("/monthOfMoneyCharts")
    public String monthOfMoneyCharts(String year){
        List<Double> moneyList = chartsService.monthOfMoneyCharts(year);
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("moneyList",moneyList);
        return JSON.toJSONString(map);
    }
}
